import { defHttp } from '/@/common/util/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/online/getTablePage',
  save = '/online/add',
  edit = '/online/edit',
  deleteOne = '/online/delete',
  updateBatch = '/online/updateBatch',
  deleteBatch = '/online/deleteBatch',
  importExcel = '/online/importExcel',
  exportXls = '/online/exportXls',

  getTableList = '/online/getTableList',      //未生成的表
  addTables = '/online/addTables',      //未生成的表
  getTableInfo = '/online/getTableInfo',      //表单生成基础信息
  getCode = '/online/getCode',      //生成代码
  getCodeView = '/online/getCodeView',      //预览代码
  getCodeViewText = '/online/getCodeViewText',      //预览代码
  getCodeViewFilePathTree = '/online/getCodeViewFilePathTree',      //预览代码
}

/**
 * 导出导入api
 * @param params
 */
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
/**
 * 增删改查接口
 */
export const list = (params) => defHttp.get({ url: Api.list, params });
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
export const deleteOne = (params) => defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true });
export const updateBatch = (params) => defHttp.post({ url: Api.updateBatch, params });
export const deleteBatch = (params) => defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true });



/**
 * 表单生成核心
 * @param params
 */
export const getTableList = (params) => defHttp.get({ url: Api.getTableList, params });
export const addTables = (params) => defHttp.post({ url: Api.addTables +'/'+ params });
export const getTableInfo = (params) => defHttp.get({ url: Api.getTableInfo, params });
export const getCode = (params) => defHttp.post({ url: Api.getCode, params });
export const getCodeView = (params) => defHttp.get({ url: Api.getCodeView, params });
export const getCodeViewText = (params) => defHttp.get({ url: Api.getCodeViewText, params });
export const getCodeViewFilePathTree = (params) => defHttp.post({ url: Api.getCodeViewFilePathTree, params });
